<?
$no_sld=translate('no_sld');
$database_error=translate('error');
$available=translate('available');
$not_available=translate('not_available');
$register=translate('register');
$not_register=translate('not_register');
$buton_check=translate('buton_check');
$message=translate('message');
if (isset($_POST[form_submit]) && $_POST[form_submit]=='yes') {
	if (empty($_POST[sld])) {
		echo "<h4><font color=red>$no_sld !</font></h4>";
	} else {
		include('/www/resellers_advanced/login/wallet_db.html');
		//-----------------------------------------------------------------------------
		$sql['type'] = "SELECT";
		$sql['params'] = "password";
		$sql['table'] = "resellers";
		$sql['where'] = "reseller_id='$id'";
		$sql['options'] = "";
		$sql['return'] = "struct";
		//------------------------------------------------------
		if (!$result=sql_exec($sql,$dbh81,'assoc')) {
			exit("$database_error");
		}
		$pass=md5($result[0][password]);
		$url="https://api.resellerspanel.com/index.php?r=$username&p=$pass&req_type=check_domain&sld=$_POST[sld]";
		$file=file($url);
		foreach ($file as $line) {
			$line=trim($line);
			if(!empty($line) && !preg_match('/entries_count/',$line)) {
				$line=explode("=",$line);
				$response[$line[0]]=$line[1];
			}
		}
		echo "<table class='bTable' cellspacing=0>";
		foreach ($response as $key=>$value) {
			if ($value==1) {
				$nkey=explode(".",$key);
				$params[sid] = $sid;
				$params[action] = 'register_domain';
				$params[sld] = $nkey[0];
				$params[tld] = $nkey[1];
				$hurl = "$baseURL/$webDIR/?".encode_params($params);
				$value="<font color=green>$available</font>";
				$href="<a href=\"$hurl\">$register</a>";
			} else {
				$value="<font color=red>$not_available</font>";
				$href=$not_register;
			}
			echo "<tr>
				<td>$key</td>
				<td>$value</td>
				<td>$href</td>
			</tr>";
		}
		echo "</table>";
		echo "<br><br>";
	}
}
$params[sid] = $sid;
$params[action] = 'check_domain_availability';
$action_url = "$baseURL/$webDIR/?".encode_params($params);
#echo "<p>$message:</p>";
echo "<table class='bTable' cellspacing=0>
<form action=\"$action_url\" method=POST>
<tr>
	<th>&nbsp;</th>
	<th>&nbsp;</th>
</tr>
<tr>
	<td><input type='text' name='sld' value='$_POST[sld]' size=15 maxlength=20></td>
	<td><input type='submit' name='submit' value='$buton_check'>
		<input type='hidden' name='form_submit' value='yes'></td>
</tr>
</form>
</table>";
?>
